package com.aaa.fpa.controller;
import  com.aaa.pojo.MyReturn;
import com.aaa.utils.Constants;
import com.aaa.utils.RetStatusEnum;
import org.springframework.web.bind.annotation.ControllerAdvice;

@ControllerAdvice
public class BaseController {
    public  MyReturn getSuccessResult(MyReturn myReturn) {
        if(null==myReturn){
            myReturn= new MyReturn();
        }
        myReturn.setCode(RetStatusEnum.SUCCESS.getCode());
        myReturn.setMsg(RetStatusEnum.SUCCESS.getMessage());
        return myReturn;
    }

    /**
     * @param myReturn
     * @return MyResult
     * @create by: Teacher陈
     * @description: 传入一个原始返回对象，得到一个失败的返回对象
     * @create time: 2020/9/17 9:39
     */
    public  MyReturn getFailResult(MyReturn myReturn) {
        if(null==myReturn){
            myReturn= new MyReturn();
        }
        myReturn.setCode(RetStatusEnum.FAILE.getCode());
        myReturn.setMsg(RetStatusEnum.FAILE.getMessage());
        return myReturn;
    }
    public  MyReturn getLoginFailResult(MyReturn myReturn) {
        if(null==myReturn){
            myReturn= new MyReturn();
        }
        myReturn.setCode(RetStatusEnum.FAILE.getCode());
        myReturn.setMsg(Constants.ERROR_LOGIN);
        return myReturn;
    }

}
